<!DOCTYPE html>
<html>
  <head>
    <title>Notifications: The Notification object exposes the expected data property.</title>
    <script src="../resources/testharness.js"></script>
    <script src="../resources/testharnessreport.js"></script>
  </head>
  <body>
    <script>
    // Tests that the Notification object exposes the data property per the
    // semantics defined by the specification. When the test is being ran
    // manually, grant Notification permission first.

    function assertNotificationDataReflects(value) {
        var notification = new Notification('Title', { data: value });

        if (typeof value === 'object')
            assert_object_equals(notification.data, value);
        else
            assert_equals(notification.data, value);
    }

    test(function () {
        // Set notification's data of several type to a structured clone of options's data.
        assertNotificationDataReflects(true);  // Check Boolean type
        assertNotificationDataReflects(1024);  // Check Number type
        assertNotificationDataReflects(Number.NaN);  // Check Number.NaN type
        assertNotificationDataReflects('any data');  // Check String type

        var cars = new Array('Saab', 'Volvo', 'BMW');
        assertNotificationDataReflects(cars); // Check Array type

        var obj = { first: 'first', second: 'second'};
        assertNotificationDataReflects(obj); // Check Object

        // Verifying the exception throwing behavior of the method.
        assert_throws_dom('DataCloneError', function() {
            var notification = new Notification('Title', { data: function() { return 1; } });
        }, 'Set function in data');

    }, 'Checks the data of several type property exposed on the Notification object.');
    </script>
  </body>
</html>
